package com.aldobucchi.core.comparison.simple.impl
{
	import mx.utils.UIDUtil;
	
	import com.aldobucchi.core.comparison.simple.ISimpleComparator;
	import com.aldobucchi.core.comparison.result.ComparisonResult; import com.aldobucchi.core.comparison.result.ComparisonResults;	
	
	/**
	 * 
	 * Compares two objects by comparing their UID, obtained using UIDUtil.getUID();
	 * If either ( or both ) of the values are not Objects, then ComparisonResults.DIFFERENT wil be returned
	 * because basic values cannot have UIDs
	 * 
	 * @author aldo.bucchi@gmail.com
	 * 
	 */	
	public class UIDSimpleComparator implements ISimpleComparator
	{
		
		public function compare(value1:*, value2:*):ComparisonResult
		{
			// we can only get the UID for objects
			if ( ! value1 is Object ) return ComparisonResults.DIFFERENT;
			if ( ! value2 is Object ) return ComparisonResults.DIFFERENT;

			return UIDUtil.getUID( value1 ) == UIDUtil.getUID( value2 ) ? ComparisonResults.EQUAL : ComparisonResults.DIFFERENT;
		}
		
	}
	
}